# Copyright 2021, Régis Décamps
# SPDX-License-Identifier: BSD-3-Clause

package(default_visibility = ["//javatests/de/jflex/ucd_generator:__subpackages__"])

java_library(
    name = "ucd_generator",
    srcs = [
        "UcdGenerator.java",
        "UcdGeneratorParams.java",
    ],
    deps = [
        "//java/de/jflex/ucd_generator/emitter/unicode_properties",
        "//java/de/jflex/ucd_generator/emitter/unicode_version",
        "//java/de/jflex/ucd_generator/scanner",
        "//java/de/jflex/ucd_generator/scanner:exception",
        "//java/de/jflex/ucd_generator/ucd",
        "//java/de/jflex/util/javac",
        "//java/de/jflex/velocity",
        "//java/de/jflex/version",
        "//third_party/com/google/auto_value",
        "//third_party/com/google/guava",
        "//third_party/org/apache/velocity",
    ],
)

java_binary(
    name = "Main",
    srcs = ["Main.java"],
    visibility = ["//visibility:public"],
    deps = [
        ":ucd_generator",
        "//java/de/jflex/ucd_generator/ucd",
        "//java/de/jflex/version",
        "//third_party/com/google/guava",
    ],
)

genrule(
    name = "gen_unicode_properties",
    srcs = [
        "//third_party/unicode:ucd_1_1_5",
        "//third_party/unicode:ucd_2_0_14",
        "//third_party/unicode:ucd_2_1_9",
        "//third_party/unicode:ucd_3_0_1",
        "//third_party/unicode:ucd_3_1_1",
        "//third_party/unicode:ucd_3_2_0",
        "//third_party/unicode:ucd_4_0_1",
        "//third_party/unicode:ucd_4_1_0",
        "//third_party/unicode:ucd_5_0",
        "//third_party/unicode:ucd_5_1",
        "//third_party/unicode:ucd_5_2",
        "//third_party/unicode:ucd_6_0",
        "//third_party/unicode:ucd_6_1",
        "//third_party/unicode:ucd_6_2",
        "//third_party/unicode:ucd_6_3",
        "//third_party/unicode:ucd_7_0",
        "//third_party/unicode:ucd_8_0",
        "//third_party/unicode:ucd_9_0",
        "//third_party/unicode:ucd_10_0",
        "//third_party/unicode:ucd_11_0",
        "//third_party/unicode:ucd_12_0",
        "//third_party/unicode:ucd_12_1",
    ],
    outs = [
        "UnicodeProperties.java",
        "Unicode_1_1.java",
        "Unicode_2_0.java",
        "Unicode_2_1.java",
        "Unicode_3_0.java",
        "Unicode_3_1.java",
        "Unicode_3_2.java",
        "Unicode_4_0.java",
        "Unicode_4_1.java",
        "Unicode_5_0.java",
        "Unicode_5_1.java",
        "Unicode_5_2.java",
        "Unicode_6_0.java",
        "Unicode_6_1.java",
        "Unicode_6_2.java",
        "Unicode_6_3.java",
        "Unicode_7_0.java",
        "Unicode_8_0.java",
        "Unicode_9_0.java",
        "Unicode_10_0.java",
        "Unicode_11_0.java",
        "Unicode_12_0.java",
        "Unicode_12_1.java",
    ],
    cmd = "$(location //java/de/jflex/ucd_generator:Main)" +
          " --version=1.1.5 $(locations //third_party/unicode:ucd_1_1_5)" +
          " --version=2.0.14 $(locations //third_party/unicode:ucd_2_0_14)" +
          " --version=2.1.9 $(locations //third_party/unicode:ucd_2_1_9)" +
          " --version=3.0.1 $(locations //third_party/unicode:ucd_3_0_1)" +
          " --version=3.1.1 $(locations //third_party/unicode:ucd_3_1_1)" +
          " --version=3.2.0 $(locations //third_party/unicode:ucd_3_2_0)" +
          " --version=4.0.1 $(locations //third_party/unicode:ucd_4_0_1)" +
          " --version=4.1.0 $(locations //third_party/unicode:ucd_4_1_0)" +
          " --version=5.0.0 $(locations //third_party/unicode:ucd_5_0)" +
          " --version=5.1.0 $(locations //third_party/unicode:ucd_5_1)" +
          " --version=5.2.0 $(locations //third_party/unicode:ucd_5_2)" +
          " --version=6.0.0 $(locations //third_party/unicode:ucd_6_0)" +
          " --version=6.1.0 $(locations //third_party/unicode:ucd_6_1)" +
          " --version=6.2.0 $(locations //third_party/unicode:ucd_6_2)" +
          " --version=6.3.0 $(locations //third_party/unicode:ucd_6_3)" +
          " --version=7.0.0 $(locations //third_party/unicode:ucd_7_0)" +
          " --version=8.0.0 $(locations //third_party/unicode:ucd_8_0)" +
          " --version=9.0.0 $(locations //third_party/unicode:ucd_9_0)" +
          " --version=10.0.0 $(locations //third_party/unicode:ucd_10_0)" +
          " --version=11.0.0 $(locations //third_party/unicode:ucd_11_0)" +
          " --version=12.0.0 $(locations //third_party/unicode:ucd_12_0)" +
          " --version=12.1.0 $(locations //third_party/unicode:ucd_12_1)" +
          " --out=$(@D)",
    tools = ["//java/de/jflex/ucd_generator:Main"],
)
